home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / 3Dmodeling / 3d.h next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  4.4 KB  |  132 lines

  1. /*
  2.  * Copyright 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. /* Tom Davis -- 1992 */
  19.  
  20. /* curve types */
  21.  
  22. #define CURVE_BEZIER    1
  23. #define CURVE_CARDINAL    2
  24. #define CURVE_BSPLINE    3
  25. #define CURVE_PWLINEAR    4
  26. #define CURVE_CUBIC    5
  27. #define CURVE_ANALYTIC    6
  28.  
  29. #define ADD_QUAD    1
  30. #define ADD_TRI        2
  31.  
  32. typedef struct Crv {
  33.     long        type;
  34.     long        *data;
  35.     struct cbl        *fctns;
  36.     long        *cache;
  37. } curve_t;
  38.  
  39. typedef struct cbl {
  40.     void    (*point)(struct Crv *, float, float [3]);
  41.     void    (*tangent)(struct Crv *, float, float [3]);
  42.     void    (*accel)(struct Crv *, float, float [3]);
  43.     void    (*cleanup)(struct Crv *);
  44. } cblock_t;
  45.  
  46. typedef struct {    /* piecewise linear curve */
  47.     long        n;
  48.     float        *verts;    /*  x0, y0, z0, x1, y1, z1, ... */
  49. } pwlin_t;
  50.  
  51. void    error(char *);
  52. void    diff3(float [3], float [3], float [3]);
  53. void    add3(float [3], float [3], float [3]);
  54. void    scalarmult(float, float [3], float [3]);
  55. float    dot3(float [3], float [3]);
  56. float    length3(float [3]);
  57. float    dist3(float [3], float [3]);
  58. void    copy3(float [3], float [3]);
  59. void    crossprod(float [3], float [3], float [3]);
  60. void    normalize(float [3]);
  61. void    print3(float [3]);
  62. void    printmat3(float [3][3]);
  63. void    identifymat3(float [3][3]);
  64. void    copymat3(float *, float *);
  65. void    xformvec3(float [3], float [3][3], float [3]);
  66. float    curvelength(curve_t *);
  67. static float    curvestep(curve_t *, long, long, float, float [3]);
  68. pwlin_t    *newpwlin();
  69. pwlin_t *makepwlin(long, float *);
  70. pwlin_t    *appendpwlins(pwlin_t *, pwlin_t *);
  71. void    freepwlin(pwlin_t *);
  72.  
  73. static void pentagon(long, long, long, long, long);
  74. void quadsphere(long, long, void (*)());
  75. void doughnut(float, float, long, long, void (*)());
  76. void elbow(float *, float *, float *,
  77.         float, long, long, void (*)());
  78. void cylinder(float *, float *,
  79.         float, long, void (*)());
  80. void trisphere(float [3], float, long, void (*)());
  81. void icosahedron(float [3], float, void (*)());
  82. void octahedron(float [3], float, void (*)());
  83. void tetrahedron(float [3], float, void (*)());
  84. void dodecahedron(float [3], float, void (*)());
  85.  
  86. void makepwlworm(curve_t *, pwlin_t *, long, void (*)());
  87. curve_t *newanalyticcurve(float (*)(float), float (*)(float), float (*)(float),
  88.         float (*)(float), float (*)(float), float (*)(float),
  89.         float (*)(float), float (*)(float), float (*)(float));
  90. curve_t *newcubiccurve(float [3], float [3], float [3], float [3]);
  91. curve_t *newbeziercurve(float [3], float [3], float [3], float [3]);
  92. curve_t *newbsplinecurve(float [3], float [3], float [3], float [3]);
  93. curve_t *newcardinalcurve(float [3], float [3], float [3], float [3]);
  94.  
  95. pwlin_t    *pwlinfromcurve(curve_t *, long);
  96. void makesmoothpwlworm(curve_t *, pwlin_t *, long, void (*)());
  97. void makepwlworm(curve_t *, pwlin_t *, long, void (*)());
  98. void makeworm(curve_t *, float, long, long, void (*)());
  99.  
  100. void smoothsave(long, float [3], float [3],
  101.         float [3], float [3], float [3],
  102.         float [3], float [3], float [3]);
  103. void solidofrevolution(pwlin_t *, long, void (*)());
  104. void smoothsolidofrevolution(pwlin_t *, long, void (*)());
  105. void doverts();
  106. void doquads();
  107.  
  108. void drawbox(float, float, float, float,
  109.         float, float, void (*)());
  110. void m_resetmatrixstack();
  111. void m_xformpt(float [3], float [3], float [3], float [3]);
  112. void m_xformptonly(float [3], float [3]);
  113. void m_pushmatrix();
  114. void m_popmatrix();
  115. void m_shear(float, float, float);
  116. void m_translate(float, float, float);
  117. void m_scale(float, float, float);
  118. void m_rotate(float, char);
  119.  
  120. void analyticsurface(float (*)(float, float), float (*)(float, float), 
  121.              float (*)(float, float), 
  122.              float (*)(float, float), float (*)(float, float), 
  123.              float (*)(float, float), 
  124.              float (*)(float, float), float (*)(float, float), 
  125.              float (*)(float, float), 
  126.              long, float, float,
  127.              long, float, float,
  128.              long, 
  129.              void (*)());
  130.  
  131.  
  132.